#include "Buffer.h"
#include <assert.h>

void EDataBuffer::expand(size_t RequiredSize)
{
	if (RequiredSize > _Size){
		int NewSize = RequiredSize % _StepSize > 0 ? RequiredSize + (_StepSize - (RequiredSize % _StepSize)) : RequiredSize;

		unsigned char* NewItems = new unsigned char[NewSize];
		assert(NewItems);
		if (_Items){
			if (_Count > 0){
				memmove(NewItems, _Items, _Count);
			}
			delete[] _Items;
		}
		_Items = NewItems;
		_Size = NewSize;
	}
}
